<template>
	<view class="service-list">
		<!-- 店铺 -->
		<view v-show="0 == index">
			<mescroll-body ref="mescrollRef" @init="mescrollInit" top="210" :down="downOption" @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
				<shop-list :list="goods" :follow="follow"></shop-list>
			</mescroll-body>
		</view>
		<!-- 套餐 -->
		<view v-show="1 == index">
			<mescroll-body ref="mescrollRef" @init="mescrollInit" top="210" :down="downOption" @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
				<meal-list :list="goods"></meal-list>
			</mescroll-body>
		</view>
		<!-- 员工 -->
		<view v-show="2 == index">
			<mescroll-body ref="mescrollRef" @init="mescrollInit" top="210" :down="downOption" @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
				<staff-list :list="goods" :follow="follow"></staff-list>
			</mescroll-body>
		</view>
	</view>
</template>

<script>
	import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue";
	import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js'
	import MescrollMoreItemMixin from '@/components/mescroll-uni/mixins/mescroll-more-item.js'
	import MealList from '@/components/list/list-meal.vue'
	import ShopList from '@/components/list/list-shop.vue'
	import StaffList from '@/components/list/list-staff.vue'
	export default {
		mixins: [MescrollMixin,MescrollMoreItemMixin], // 注意此处还需使用MescrollMoreItemMixin (必须写在MescrollMixin后面)
		components: {
			MescrollBody,
			MealList,
			ShopList,
			StaffList
		},
		data() {
			return {
				downOption:{
					auto:false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				goods: [], //列表数据
				page:0,
				size:1
			}
		},
		props: {
			follow:false
		},
		methods: {
			//下拉刷新的回调
			downCallback() {
				var _this = this
				_this.$http
					.get('/lookfor/service/getemployaboutbusinessorenterprise/en/1',{
						page:1,
						size:_this.size
					})
					.then(function(response) {
						console.log('个人信息', response);
						//联网成功的回调,隐藏下拉刷新的状态
						_this.mescroll.endSuccess();
						_this.goods = response.data
					})
					.catch(function(error) {
						console.log('error111111',error);
						this.mescroll.endErr();
					});
			},
			//上拉加载的回调
			upCallback(page) {
				var _this = this
				_this.page = _this.page + 1
				console.log(_this.page)
				_this.$http
					.get('/lookfor/service/getemployaboutbusinessorenterprise/en/1',{
						page:_this.page,
						size:_this.size
					})
					.then(function(response) {
						console.log('个人信息111111111111', response);
						console.log(111)
						if(_this.page > response.msg){
							_this.mescroll.endErr();
							_this.page = _this.page - 1
							uni.showToast({
								icon: 'none',
								position: 'bottom',
								title: '没有更多数据啦~'
							});
						}else{
							_this.mescroll.endSuccess();
							//设置列表数据
							_this.goods=_this.goods.concat(response.data);
						}
						
					})
					.catch(function(error) {
						console.log('error22222222',error);
						_this.mescroll.endErr();
					});
			}
		}
	}
</script>

<style lang="scss">
.all-list{
	
}
</style>
